// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   querya.java

package include.query;

import include.nseer_db.nseer_db;
import java.sql.ResultSet;

public class querya
{

	private String dbase;
	private String tableName;
	private String timea;
	private String timeb;
	private String marketarea;
	private String sales;
	private String trade;
	private String trade1;
	private String trade2;
	private String trade3;
	private String trade4;
	private String trade5;
	private String fieldName;
	private String fieldName1;
	private String fieldName2;
	private String fieldName3;
	private String fieldName4;
	private String realname;
	private String condition;
	private String queue;
	private String tagq;
	private String area;
	private String sql;
	private String sql1;
	private String sql2;
	private String sql3;
	private String sql4;
	private String sql5;
	private String sql6;
	private String sql7;
	private String sql8;
	private nseer_db dba;
	private nseer_db dbb;
	private ResultSet rs;
	private ResultSet rs1;
	private ResultSet rs2;
	private ResultSet rs3;
	private ResultSet rs4;
	private ResultSet rs5;
	private ResultSet rs6;
	private ResultSet rs7;
	private ResultSet rs8;
	private int intRowCount;
	private double tradeTotal;
	private double profitTotal;
	private int backTimeTotal;
	private double bonus;
	private double receipt;

	public querya()
	{
		dbase = "";
		tableName = "";
		timea = "";
		timeb = "";
		marketarea = "";
		sales = "";
		trade = "";
		trade1 = "";
		trade2 = "";
		trade3 = "";
		trade4 = "";
		trade5 = "";
		fieldName = "";
		fieldName1 = "";
		fieldName2 = "";
		fieldName3 = "";
		fieldName4 = "";
		realname = "";
		condition = "";
		queue = "";
		tagq = "";
		area = "";
		sql = "";
		sql1 = "";
		sql2 = "";
		sql3 = "";
		sql4 = "";
		sql5 = "";
		sql6 = "";
		sql7 = "";
		sql8 = "";
		rs = null;
		rs1 = null;
		rs2 = null;
		rs3 = null;
		rs4 = null;
		rs5 = null;
		rs6 = null;
		rs7 = null;
		rs8 = null;
		intRowCount = 0;
		tradeTotal = 0.0D;
		profitTotal = 0.0D;
		backTimeTotal = 0;
		bonus = 0.0D;
		receipt = 0.0D;
	}

	public ResultSet queryDB(String dbase, String tName, String uTimea, String uTimeb, String uMarketarea, String uSales, String uTrade, 
			String fName1, String fName2, String fName3, String fName4, String uCondition, String uQueue, String rName)
	{
		this.dbase = dbase;
		tableName = tName;
		timea = uTimea;
		timeb = uTimeb;
		marketarea = uMarketarea;
		sales = uSales;
		trade = uTrade;
		fieldName1 = fName1;
		fieldName2 = fName2;
		fieldName3 = fName3;
		fieldName4 = fName4;
		condition = uCondition;
		queue = uQueue;
		realname = rName;
		dba = new nseer_db(dbase);
		dbb = new nseer_db(dbase);
		try
		{
			sql8 = (new StringBuilder("select * from editor where realname='")).append(realname).append("'").toString();
			rs8 = dbb.executeQuery(sql8);
			if (rs8.next())
			{
				tagq = rs8.getString("tagq");
				area = rs8.getString("marketarea");
			}
			dbb.close();
			if (tagq.equals("1"))
				sales = realname;
			if (tagq.equals("2"))
				marketarea = area;
			if (!trade.equals(""))
			{
				sql6 = (new StringBuilder("select * from customer where customername='")).append(trade).append("'").toString();
				ResultSet rs6 = dbb.executeQuery(sql6);
				if (rs6.next())
				{
					trade1 = rs6.getString("customername1");
					trade2 = rs6.getString("customername2");
					trade3 = rs6.getString("customername3");
					trade4 = rs6.getString("customername4");
					trade5 = rs6.getString("customername5");
				}
				dbb.close();
			}
			if (timea.equals("") && timeb.equals("") && marketarea.equals("") && sales.equals("") && trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(condition).append(" ").append(queue).toString();
			else
			if (!timea.equals("") && timeb.equals("") && marketarea.equals("") && (sales.equals("") || sales == null) && trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName1).append(">='").append(timea).append("' and ").append(condition).append(" ").append(queue).toString();
			else
			if (timea.equals("") && !timeb.equals("") && marketarea.equals("") && (sales.equals("") || sales == null) && trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName1).append("<='").append(timeb).append("' and ").append(condition).append(" ").append(queue).toString();
			else
			if (timea.equals("") && timeb.equals("") && !marketarea.equals("") && (sales.equals("") || sales == null) && trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName2).append("='").append(marketarea).append("' and ").append(condition).append(" ").append(queue).toString();
			else
			if (timea.equals("") && timeb.equals("") && marketarea.equals("") && !sales.equals("") && sales != null && trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName4).append("='").append(sales).append("' and ").append(condition).append(" ").append(queue).toString();
			else
			if (timea.equals("") && timeb.equals("") && marketarea.equals("") && (sales.equals("") || sales == null) && !trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where (").append(fieldName3).append("='").append(trade).append("' or ").append(fieldName3).append("='").append(trade1).append("' or ").append(fieldName3).append("='").append(trade2).append("' or ").append(fieldName3).append("='").append(trade3).append("' or ").append(fieldName3).append("='").append(trade4).append("' or ").append(fieldName3).append("='").append(trade5).append("') and ").append(condition).append(" ").append(queue).toString();
			else
			if (!timea.equals("") && !timeb.equals("") && !marketarea.equals("") && !sales.equals("") && sales != null && !trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName1).append(">='").append(timea).append("' and ").append(fieldName1).append("<='").append(timeb).append("' and ").append(fieldName2).append("='").append(marketarea).append("' and ").append(fieldName4).append("='").append(sales).append("' and (").append(fieldName3).append("='").append(trade).append("' or ").append(fieldName3).append("='").append(trade1).append("' or ").append(fieldName3).append("='").append(trade2).append("' or ").append(fieldName3).append("='").append(trade3).append("' or ").append(fieldName3).append("='").append(trade4).append("' or ").append(fieldName3).append("='").append(trade5).append("') and ").append(condition).append(" ").append(queue).toString();
			else
			if (timea.equals("") && !timeb.equals("") && !marketarea.equals("") && !sales.equals("") && sales != null && !trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName1).append("<='").append(timeb).append("' and ").append(fieldName2).append("='").append(marketarea).append("' and ").append(fieldName4).append("='").append(sales).append("' and (").append(fieldName3).append("='").append(trade).append("' or ").append(fieldName3).append("='").append(trade1).append("' or ").append(fieldName3).append("='").append(trade2).append("' or ").append(fieldName3).append("='").append(trade3).append("' or ").append(fieldName3).append("='").append(trade4).append("' or ").append(fieldName3).append("='").append(trade5).append("') and ").append(condition).append(" ").append(queue).toString();
			else
			if (!timea.equals("") && timeb.equals("") && !marketarea.equals("") && !sales.equals("") && sales != null && !trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName1).append(">='").append(timea).append("' and ").append(fieldName2).append("='").append(marketarea).append("' and ").append(fieldName4).append("='").append(sales).append("' and (").append(fieldName3).append("='").append(trade).append("' or ").append(fieldName3).append("='").append(trade1).append("' or ").append(fieldName3).append("='").append(trade2).append("' or ").append(fieldName3).append("='").append(trade3).append("' or ").append(fieldName3).append("='").append(trade4).append("' or ").append(fieldName3).append("='").append(trade5).append("') and ").append(condition).append(" ").append(queue).toString();
			else
			if (!timea.equals("") && !timeb.equals("") && marketarea.equals("") && !sales.equals("") && sales != null && !trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName1).append(">='").append(timea).append("' and ").append(fieldName1).append("<='").append(timeb).append("' and ").append(fieldName4).append("='").append(sales).append("' and (").append(fieldName3).append("='").append(trade).append("' or ").append(fieldName3).append("='").append(trade1).append("' or ").append(fieldName3).append("='").append(trade2).append("' or ").append(fieldName3).append("='").append(trade3).append("' or ").append(fieldName3).append("='").append(trade4).append("' or ").append(fieldName3).append("='").append(trade5).append("') and ").append(condition).append(" ").append(queue).toString();
			else
			if (!timea.equals("") && !timeb.equals("") && !marketarea.equals("") && (sales.equals("") || sales == null) && !trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName1).append(">='").append(timea).append("' and ").append(fieldName1).append("<='").append(timeb).append("' and ").append(fieldName2).append("='").append(marketarea).append("' and (").append(fieldName3).append("='").append(trade).append("' or ").append(fieldName3).append("='").append(trade1).append("' or ").append(fieldName3).append("='").append(trade2).append("' or ").append(fieldName3).append("='").append(trade3).append("' or ").append(fieldName3).append("='").append(trade4).append("' or ").append(fieldName3).append("='").append(trade5).append("') and ").append(condition).append(" ").append(queue).toString();
			else
			if (!timea.equals("") && !timeb.equals("") && !marketarea.equals("") && !sales.equals("") && sales != null && trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName1).append(">='").append(timea).append("' and ").append(fieldName1).append("<='").append(timeb).append("' and ").append(fieldName2).append("='").append(marketarea).append("' and ").append(fieldName4).append("='").append(sales).append("' and ").append(condition).append(" ").append(queue).toString();
			else
			if (!timea.equals("") && !timeb.equals("") && marketarea.equals("") && (sales.equals("") || sales == null) && trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName1).append(">='").append(timea).append("' and ").append(fieldName1).append("<='").append(timeb).append("' and ").append(condition).append(" ").append(queue).toString();
			else
			if (!timea.equals("") && timeb.equals("") && !marketarea.equals("") && (sales.equals("") || sales == null) && trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName1).append(">='").append(timea).append("' and ").append(fieldName2).append("='").append(marketarea).append("' and ").append(condition).append(" ").append(queue).toString();
			else
			if (!timea.equals("") && timeb.equals("") && marketarea.equals("") && !sales.equals("") && sales != null && trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName1).append(">='").append(timea).append("' and ").append(fieldName4).append("='").append(sales).append("' and ").append(condition).append(" ").append(queue).toString();
			else
			if (!timea.equals("") && timeb.equals("") && marketarea.equals("") && (sales.equals("") || sales == null) && !trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName1).append(">='").append(timea).append("' and (").append(fieldName3).append("='").append(trade).append("' or ").append(fieldName3).append("='").append(trade1).append("' or ").append(fieldName3).append("='").append(trade2).append("' or ").append(fieldName3).append("='").append(trade3).append("' or ").append(fieldName3).append("='").append(trade4).append("' or ").append(fieldName3).append("='").append(trade5).append("') and ").append(condition).append(" ").append(queue).toString();
			else
			if (timea.equals("") && !timeb.equals("") && !marketarea.equals("") && (sales.equals("") || sales == null) && trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName1).append("<='").append(timeb).append("' and ").append(fieldName2).append("='").append(marketarea).append("' and ").append(condition).append(" ").append(queue).toString();
			else
			if (timea.equals("") && !timeb.equals("") && marketarea.equals("") && !sales.equals("") && sales != null && trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName1).append("<='").append(timeb).append("' and ").append(fieldName4).append("='").append(sales).append("' and ").append(condition).append(" ").append(queue).toString();
			else
			if (!timea.equals("") && !timeb.equals("") && marketarea.equals("") && (sales.equals("") || sales == null) && !trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName1).append("<='").append(timeb).append("' and (").append(fieldName3).append("='").append(trade).append("' or ").append(fieldName3).append("='").append(trade1).append("' or ").append(fieldName3).append("='").append(trade2).append("' or ").append(fieldName3).append("='").append(trade3).append("' or ").append(fieldName3).append("='").append(trade4).append("' or ").append(fieldName3).append("='").append(trade5).append("') and ").append(condition).append(" ").append(queue).toString();
			else
			if (timea.equals("") && timeb.equals("") && !marketarea.equals("") && !sales.equals("") && sales != null && trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName2).append("='").append(marketarea).append("' and ").append(fieldName4).append("='").append(sales).append("' and ").append(condition).append(" ").append(queue).toString();
			else
			if (timea.equals("") && timeb.equals("") && !marketarea.equals("") && (sales.equals("") || sales == null) && !trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName2).append("='").append(marketarea).append("' and (").append(fieldName3).append("='").append(trade).append("' or ").append(fieldName3).append("='").append(trade1).append("' or ").append(fieldName3).append("='").append(trade2).append("' or ").append(fieldName3).append("='").append(trade3).append("' or ").append(fieldName3).append("='").append(trade4).append("' or ").append(fieldName3).append("='").append(trade5).append("') and ").append(condition).append(" ").append(queue).toString();
			else
			if (timea.equals("") && timeb.equals("") && marketarea.equals("") && !sales.equals("") && sales != null && !trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName4).append("='").append(sales).append("' and (").append(fieldName3).append("='").append(trade).append("' or ").append(fieldName3).append("='").append(trade1).append("' or ").append(fieldName3).append("='").append(trade2).append("' or ").append(fieldName3).append("='").append(trade3).append("' or ").append(fieldName3).append("='").append(trade4).append("' or ").append(fieldName3).append("='").append(trade5).append("') and ").append(condition).append(" ").append(queue).toString();
			else
			if (!timea.equals("") && !timeb.equals("") && !marketarea.equals("") && (sales.equals("") || sales == null) && trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName1).append(">='").append(timea).append("' and ").append(fieldName1).append("<='").append(timeb).append("' and ").append(fieldName2).append("='").append(marketarea).append("' and ").append(condition).append(" ").append(queue).toString();
			else
			if (!timea.equals("") && !timeb.equals("") && marketarea.equals("") && !sales.equals("") && sales != null && trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName1).append(">='").append(timea).append("' and ").append(fieldName1).append("<='").append(timeb).append("' and ").append(fieldName4).append("='").append(sales).append("' and ").append(condition).append(" ").append(queue).toString();
			else
			if (!timea.equals("") && !timeb.equals("") && marketarea.equals("") && (sales.equals("") || sales == null) && !trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName1).append(">='").append(timea).append("' and ").append(fieldName1).append("<='").append(timeb).append("' and (").append(fieldName3).append("='").append(trade).append("' or ").append(fieldName3).append("='").append(trade1).append("' or ").append(fieldName3).append("='").append(trade2).append("' or ").append(fieldName3).append("='").append(trade3).append("' or ").append(fieldName3).append("='").append(trade4).append("' or ").append(fieldName3).append("='").append(trade5).append("') and ").append(condition).append(" ").append(queue).toString();
			else
			if (timea.equals("") && !timeb.equals("") && !marketarea.equals("") && !sales.equals("") && sales != null && trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName1).append("<='").append(timeb).append("' and ").append(fieldName2).append("='").append(marketarea).append("' and ").append(fieldName4).append("='").append(sales).append("' and ").append(condition).append(" ").append(queue).toString();
			else
			if (timea.equals("") && !timeb.equals("") && !marketarea.equals("") && (sales.equals("") || sales == null) && !trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName1).append("<='").append(timeb).append("' and ").append(fieldName2).append("='").append(marketarea).append("' and (").append(fieldName3).append("='").append(trade).append("' or ").append(fieldName3).append("='").append(trade1).append("' or ").append(fieldName3).append("='").append(trade2).append("' or ").append(fieldName3).append("='").append(trade3).append("' or ").append(fieldName3).append("='").append(trade4).append("' or ").append(fieldName3).append("='").append(trade5).append("') and ").append(condition).append(" ").append(queue).toString();
			else
			if (timea.equals("") && timeb.equals("") && !marketarea.equals("") && !sales.equals("") && sales != null && !trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName2).append("='").append(marketarea).append("' and ").append(fieldName4).append("='").append(sales).append("' and (").append(fieldName3).append("='").append(trade).append("' or ").append(fieldName3).append("='").append(trade1).append("' or ").append(fieldName3).append("='").append(trade2).append("' or ").append(fieldName3).append("='").append(trade3).append("' or ").append(fieldName3).append("='").append(trade4).append("' or ").append(fieldName3).append("='").append(trade5).append("') and ").append(condition).append(" ").append(queue).toString();
			else
			if (!timea.equals("") && timeb.equals("") && !marketarea.equals("") && (sales.equals("") || sales == null) && !trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName1).append(">='").append(timea).append("' and ").append(fieldName2).append("='").append(marketarea).append("' and (").append(fieldName3).append("='").append(trade).append("' or ").append(fieldName3).append("='").append(trade1).append("' or ").append(fieldName3).append("='").append(trade2).append("' or ").append(fieldName3).append("='").append(trade3).append("' or ").append(fieldName3).append("='").append(trade4).append("' or ").append(fieldName3).append("='").append(trade5).append("') and ").append(condition).append(" ").append(queue).toString();
			else
			if (timea.equals("") && !timeb.equals("") && marketarea.equals("") && !sales.equals("") && sales != null && !trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName1).append("<='").append(timeb).append("' and ").append(fieldName4).append("='").append(sales).append("' and (").append(fieldName3).append("='").append(trade).append("' or ").append(fieldName3).append("='").append(trade1).append("' or ").append(fieldName3).append("='").append(trade2).append("' or ").append(fieldName3).append("='").append(trade3).append("' or ").append(fieldName3).append("='").append(trade4).append("' or ").append(fieldName3).append("='").append(trade5).append("') and ").append(condition).append(" ").append(queue).toString();
			else
			if (!timea.equals("") && timeb.equals("") && !marketarea.equals("") && !sales.equals("") && sales != null && trade.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName1).append(">='").append(timea).append("' and ").append(fieldName2).append("='").append(marketarea).append("' and ").append(fieldName4).append("='").append(sales).append("' and ").append(condition).append(" ").append(queue).toString();
			else
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName1).append(">='").append(timea).append("' and ").append(fieldName4).append("='").append(sales).append("' and (").append(fieldName3).append("='").append(trade).append("' or ").append(fieldName3).append("='").append(trade1).append("' or ").append(fieldName3).append("='").append(trade2).append("' or ").append(fieldName3).append("='").append(trade3).append("' or ").append(fieldName3).append("='").append(trade4).append("' or ").append(fieldName3).append("='").append(trade5).append("') and ").append(condition).append(" ").append(queue).toString();
			rs = dba.executeQuery(sql);
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
		return rs;
	}

	public int intRowCount()
	{
		try
		{
			dbb = new nseer_db(dbase);
			sql1 = sql;
			rs1 = dbb.executeQuery(sql1);
			intRowCount = 0;
			if (rs1.last())
				intRowCount = rs1.getRow();
			dbb.close();
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
		return intRowCount;
	}

	public void close()
	{
		dba.close();
	}

	public double sumTotal(String fName)
	{
		try
		{
			fieldName = fName;
			dbb = new nseer_db(dbase);
			sql2 = sql;
			rs2 = dbb.executeQuery(sql2);
			for (tradeTotal = 0.0D; rs2.next(); tradeTotal += rs2.getDouble(fieldName));
			dbb.close();
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
		return tradeTotal;
	}

	public int intTotal(String fName)
	{
		try
		{
			fieldName = fName;
			dbb = new nseer_db(dbase);
			sql4 = sql;
			backTimeTotal = 0;
			for (rs4 = dbb.executeQuery(sql4); rs4.next();)
				backTimeTotal += rs4.getInt(fieldName);

			dbb.close();
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
		return backTimeTotal;
	}
}
